package com.xtaller.business.a.client;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * Created by Taller on 2017/8/6.
 */
@FeignClient(name = "business-b",
        fallback = BClient.ServiceBClientFallback.class)
public interface BClient {

    @GetMapping(value = "/v1")
    String printServiceB();

    @Component
    class ServiceBClientFallback implements BClient {

        private static final Logger LOGGER = LoggerFactory.getLogger(ServiceBClientFallback.class);

        @Override
        public String printServiceB() {
            LOGGER.info("异常发生，进入fallback方法");
            return "SERVICE B FAILED! - FALLING BACK";
        }
    }
}
